classdef ParseTabSepData < ParseData
  % Base parsing class for tab-separated data
  % Derived from ParseData
  % C-tor sig: parser = ParseTabSepData(dataFilename); arg required
  %     dataFilename: the path of the file containing the data to be parsed;
  %                   may be empty
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: 9/15/2011
    
    properties
      % Inherited from ParseData
      % dataFilename
    end
    
    methods
        function parser = ParseTabSepData(dataFilename) % C-tor
            parser = parser@ParseData(dataFilename);
        end
        
    end
    
    methods(Static)
        function [tok, rem] = read2tab(s, borderOfLine)
            if nargin < 2
                if (length(s)==0)
                    borderOfLine = true;
                else
                    borderOfLine = false;
                end
            end
            % char(9) = tab
            check4leadingtabs = (s == char(9));
            if isempty(check4leadingtabs)
                tok = check4leadingtabs;
                rem = check4leadingtabs;
            elseif (check4leadingtabs(1) && borderOfLine) || all(check4leadingtabs(1:2))
                tok = 'MISSING';
                rem = s(2:end);
            else
                [tok, rem] = strtok(s, char(9));
            end
        end        
    end
    
end

